package com.weike.wk_android.presenter;

import android.content.Context;

import com.weike.wk_android.contract.RegisterContract;
import com.weike.wk_android.model.Register;
import com.weike.wk_android.model.UserInfo;
import com.weike.wk_android.utils.RetrofitUtils;
import com.weike.wk_android.utils.RxHelper;

import io.reactivex.Observer;
import io.reactivex.disposables.Disposable;

public class RegisterPresenter implements RegisterContract.Presenter {
    private Context context;
    private RegisterContract.View view;

    public RegisterPresenter(Context context, RegisterContract.View view){
        this.context = context;
        this.view = view;

        // P—V绑定
        view.setPresenter(this);
    }

    @Override
    public void register(Register register) {
        RetrofitUtils.getApi().register(register)
                .compose(RxHelper.observableIO2Main(context))
                .subscribe(new Observer<UserInfo>() {
                    @Override
                    public void onSubscribe(Disposable d) {

                    }

                    @Override
                    public void onNext(UserInfo userInfo) {

                    }

                    @Override
                    public void onError(Throwable e) {

                    }

                    @Override
                    public void onComplete() {

                    }
                });
    }

    @Override
    public void start() {

    }
}
